import { View } from "../../../mvc/core/View";
import { PageTool } from "../../../common/global/PageTool";
import { ObjCreate } from "../common/ObjCreate";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { MarketMyGoodsRenderer } from "./MarketMyGoodsRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
//class SelfGoodsPanel
    
    export  class SelfGoodsPanel extends View
    {
        constructor()
        {
            super();
            this._pageTool = new PageTool([], 5);
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._bg = ObjCreate.createBg(0, 0, 275, 265, this);
            this._titleList = new GTileList();
            this._titleList.setSize(275, 250);
            this._titleList.columnWidth = 260;
            this._titleList.rowHeight = 50;
            this._titleList.direction = ScrollBarDirection.VERTICAL;
            this._titleList.horizontalGap = 0;
            this._titleList.verticalGap = 0;
            this._titleList.width = width + 15;
            this._titleList.height = height;
            this._titleList.styleName = "TileList";
            this._titleList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._titleList.setStyle("cellRenderer", MarketMyGoodsRenderer);
            this._titleList.move(0, 0);
            this._titleList.dataProvider = new DataProvider();
            addChild(this._titleList);
            this._pagebar = new PageSelecter();
            this._pagebar.mode = PageSelecter.SingleMode;
            this._pagebar.move(100, 275);
            this._pagebar.maxPage = 1;
            this._pagebar.currentPage = 1;
            addChild(this._pagebar);
            this._pagebar.addEventListener(flash.events.Event.CHANGE, this.onPageChangeHandler);
            return;
        }

        public updateDataProvider(arg1: Array<any>): void
        {
            this._pageTool.array = arg1;
            this._pagebar.maxPage = Math.ceil(arg1.length / 5);
            this.onPageChangeHandler();
            return;
        }

        /* internal  */onPageChangeHandler(arg1: Object /* flash.events.Event */=null): void
        {
            var loc1=this._pagebar.currentPage;
            var loc2=this._pageTool.getByPageNo(loc1);
            this._titleList.dataProvider = new DataProvider(loc2);
            return;
        }

        public setPanel(): void
        {
            this._bg.width = 287;
            this._pagebar.x = 110;
            return;
        }

        /* internal */ /* var */_titleList: GTileList;

        /* internal */ /* var */_pagebar: PageSelecter;

        /* internal */ /* var */_pageTool: PageTool;

        /* internal */ /* var */_bg: ScaleBitmap;
    }
